package com.listenter;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebListener;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


/**
 * 定义我们自己的ServletContextListener
 */
@WebListener
public class Studenlistener implements ServletContextListener {
    /**
     * ServletContext启动的时候调用的方法
     * @param sce
     */
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("容器执行了初始化操作");
        //表示全局设置ServletContext对应的字符编码
       // sce.getServletContext().setRequestCharacterEncoding("utf-8");
    }

    /**
     * ServletContext销毁的时候调用的方法
     * @param sce
     */
    @Override
    public void contextDestroyed(ServletContextEvent sce) {

        System.out.println("容器执行了终止操作");
    }
}

